package com.rainng.coursesystem.controller.teacher;

import com.rainng.coursesystem.config.themis.annotation.Teacher;
import com.rainng.coursesystem.controller.BaseController;
import com.rainng.coursesystem.model.entity.CourseEntity;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.service.teacher.CourseService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Teacher
@RequestMapping("/teacher/course")
@RestController("teacher_courseController")
public class CourseController extends BaseController {
    private final CourseService service;
    private final CourseService  courseService;
    @PostMapping("/createcret")
    public ResultVO createcret(@RequestBody @Validated CourseEntity entity) {
        return service.create(entity);
    }

    public CourseController(CourseService service, CourseService courseService) {
        this.service = service;
        this.courseService = courseService;
    }

    @GetMapping
    public ResultVO list() {
        return  service.list();
    }

    @GetMapping("/{id}")
    public ResultVO get(@PathVariable Integer id) {
        return courseService.get(id);
    }

    @PostMapping
    public ResultVO create(@RequestBody @Validated CourseEntity entity) {
        return courseService.create(entity);
    }

    @PutMapping
    public ResultVO update(@RequestBody @Validated CourseEntity entity) {
        return courseService.update(entity);
    }

    @DeleteMapping("/{id}")
    public ResultVO delete(@PathVariable Integer id) {
        return courseService.delete(id);
    }
}
